home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libobj / grid.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  1.9 KB  |  66 lines

  1. /*
  2.  * grid.h
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * grid.h,v 4.1 1994/08/09 07:59:10 explorer Exp
  17.  *
  18.  * grid.h,v
  19.  * Revision 4.1  1994/08/09  07:59:10  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:09  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  14:38:07  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29. #ifndef GRID_H
  30. #define GRID_H
  31.  
  32. #define GeomGridCreate(x,y,z)    GeomCreate((GeomRef)GridCreate(x,y,z), \
  33.                     GridMethods())
  34. /*
  35.  * Convert from voxel number along X/Y/Z to corresponding coordinate.
  36.  */
  37. #define voxel2x(g,x)        ((x) * g->voxsize[0] + g->bounds[0][0])
  38. #define voxel2y(g,y)        ((y) * g->voxsize[1] + g->bounds[0][1])
  39. #define voxel2z(g,z)        ((z) * g->voxsize[2] + g->bounds[0][2])
  40. /*
  41.  * And vice-versa.
  42.  */
  43. #define x2voxel(g,x)        (((x) - g->bounds[0][0]) / g->voxsize[0])
  44. #define y2voxel(g,y)        (((y) - g->bounds[0][1]) / g->voxsize[1])
  45. #define z2voxel(g,z)        (((z) - g->bounds[0][2]) / g->voxsize[2])
  46.  
  47. /*
  48.  * Grid object
  49.  */
  50. typedef struct {
  51.     short    xsize, ysize, zsize;    /* # of voxels along each axis */
  52.     Float    bounds[2][3];        /* bounding box */
  53.     Float    voxsize[3];        /* size of a voxel */
  54.     struct    Geom    *unbounded,    /* unbounded objects */
  55.             *objects;    /* all bounded objects */
  56.     struct    GeomList    ****cells;    /* Voxels */
  57. } Grid;
  58.  
  59. extern char    *GridName();
  60. extern void    *GirdBounds();
  61. extern int    GridIntersect(), GridConvert();
  62. extern Grid    *GridCreate();
  63. extern Methods    *GridMethods();
  64.  
  65. #endif /* GRID_H */
  66.